SQLite in Android
Table of Contents
1. TODO SQLite
When we need to store massive and structural data, as well as complicated queries, sorting, filtering or transaction, we should probably use SQLite. SQLite is built-in feature in Android.
1.1. How to Use?
The core class is SQLiteOpenHelper which abstracts away creation, update and downgrade.
- Creation. When DB is first accessed, Android detects if the DB file exists. If not, then
onCreate()method is invoked to execute table creation and data initialization. - Upgrade. Upon app upgrade or DB version upgrade, Android invokes
onUpgrade()to migrate data or modify table structure. - Downgrade. When DB version downgrades, Android invokes
onDowngrade().
About Storage. The DB file is stored under /data/data/<package_name>/databases/.